package com.bush.mall.coupon.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.coupon.entity.SeckillPromotionEntity;
import com.bush.mall.coupon.service.SeckillPromotionService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 秒杀活动
 * @author RUN
 * @date 2022-11-29
 */
@RestController
@RequestMapping("seckillpromotion")
@Api(tags = "秒杀活动管理" )
public class SeckillPromotionController {

    @Resource(name= SeckillPromotionService.BEAN_ID)
    private SeckillPromotionService seckillPromotionService;

    /**
     * 分页查询秒杀活动列表
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "分页查询秒杀活动列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return seckillPromotionService.queryForPage(current,size);
    }

    /**
     * 保存秒杀活动表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "保存秒杀活动表单")
    @PostMapping
    public Result saveSeckillPromotion(@RequestBody SeckillPromotionEntity seckillPromotion){
        return seckillPromotionService.saveSeckillPromotion(seckillPromotion);
    }

    /**
     * 修改秒杀活动表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "修改秒杀活动表单")
    @PutMapping
    public Result updateSeckillPromotion(@RequestBody SeckillPromotionEntity seckillPromotion){
        return seckillPromotionService.updateSeckillPromotion(seckillPromotion);
    }

    /**
     * 通过指定id删除秒杀活动
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "通过指定id删除秒杀活动")
    @DeleteMapping
    public Result deleteSeckillPromotion(Long id){
        return seckillPromotionService.deleteSeckillPromotion(id);
    }

}
